<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>JS桥测试</title>
</head>

<body>

    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    
	<div id="app">

		<button @click="pushPage">新建窗口</button>
		<p></p>

		<button @click="popPage">关闭窗口</button>
		<p></p>

		<button @click="flashOn">打开闪光灯</button>
		<p></p>

		<button @click="flashOff">关闭闪光灯</button>
		<p></p>

		<button @click="vibrationOn">马达振动</button>
		<p></p>

		<button @click="dialPhone">拨打电话</button>
		<p></p>

		<button @click="scanQRCode">扫二维码</button>
		<p></p>

		<button @click="echartPie">饼图数据</button>
		<p></p>

		<button @click="echartLineThousand">水位总功数据(千)</button>
		<p></p>

		<button @click="echartLineTenThousand">水位总功数据(万)</button>
		<p></p>

		<button @click="loginGetToken">登录</button>
		<p></p>

        {{ message }}
		<p></p>
	</div>


</body>

</html>

<script>
	var app = new Vue({
      el: '#app',
      data: {
        message: 'Hello Vue!'
      },
      mounted:function(){
        window['callJS'] = (message) => {
          this.callJS(message);
        }
       },
      methods:{
        callJS: function (message) {
          this.message = message;
        },
        pushPage:function(){
            JSBridge.postMessage('{"func":"navigator","action":"push","title":"SomeTitle","url":"http://emberwei.gitee.io/js_bridge_test_page/"}');
        },
        popPage:function(){
            JSBridge.postMessage('{"func":"navigator","action":"pop"}');
        },
        flashOn:function(){
            JSBridge.postMessage('{"func":"flash","action":"on"}');
        },
        flashOff:function(){
            JSBridge.postMessage('{"func":"flash","action":"off"}');
        },
        vibrationOn:function(){
            JSBridge.postMessage('{"func":"vibration","action":"on"}');
        },
        dialPhone:function(){
            JSBridge.postMessage('{"func":"launcher","action":"dial","phone":"18046012345"}');
        },
        scanQRCode:function(){
            JSBridge.postMessage('{"func":"qrcode","action":"scan"}');
        },
        echartPie:function(){
            JSBridge.postMessage('{"func":"echart","action":"pieDemo"}');
        },
        echartLineThousand:function() {
            JSBridge.postMessage('{"func":"echart","action":"linePowerWater","limit":"1000"}');
        },
        echartLineTenThousand:function(){
            JSBridge.postMessage('{"func":"echart","action":"linePowerWater","limit":"10000"}');
        },
        loginGetToken:function(){
            JSBridge.postMessage('{"func":"login","action":"getToken","accountName":"ld_show","accountPwd":"49ba59abbe56e057"}');
        },
      }
    })
</script>